﻿#pragma once
#include "Common.h"
#include "CentralCache.h"


class ThreadCache
{
	FreeList _freeList[NFREELIST];
public:
	// 申请内存对象 
	void* Allocate(size_t sz);
	//释放内存对象
	void Deallocate(void* ptr, size_t sz);
	// 从中⼼缓存获取对象 
	void* FetchFromCentralCache(size_t index, size_t alignNum);
	
	void ListTooLong(FreeList& freeList, size_t sz);
};

// TLS thread local storage
static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;
